package com.chengccn.spring.hello;

import com.chengccn.spring.hello.entity.Cat;
import com.chengccn.spring.hello.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author: Administrator
 * @Description:
 * @Date: 2019/5/17 15:42
 * @Version: 1.0
 */
public class MyTest {
    public static void main(String[] args) {
        // 获取 Spring 容器
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-context.xml");

        // 从 Spring 容器中获取对象
        UserService userService = (UserService) applicationContext.getBean("userService");
        userService.sayHi();

        Cat cat = (Cat) applicationContext.getBean("cat");
        System.out.println(cat.getName());
    }
}
